package com.stylefeng.guns.modular.owBackstageMgr.mmMgr.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.model.MemberMien;
import com.stylefeng.guns.modular.system.dao.MemberMienMapper;
import com.stylefeng.guns.modular.owBackstageMgr.mmMgr.service.IMemberMienService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.model.News;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会员风采 服务实现类
 * </p>
 *
 * @author huangyuehong123
 * @since 2018-07-16
 */
@Service
public class MemberMienServiceImpl extends ServiceImpl<MemberMienMapper, MemberMien> implements IMemberMienService {

    /**
     * 根据条件获取会员风采列表
     */
    @Override
    public List<Map<String, Object>> getMMList(Page<MemberMien> page, String beginTime, String endTime, String name, String orderByField, boolean isAsc) {
        return this.baseMapper.getMMList(page,beginTime,endTime,name,orderByField,isAsc);
    }

    /**
     * 按orderval字段排序，获取前num条的会员风采记录
     */
    @Override
    public List<MemberMien> getNumMMs(Integer num, boolean isAsc) {
        EntityWrapper<MemberMien> wrapper = new EntityWrapper<>();
        wrapper.eq("is_del",0);
        wrapper.orderBy("orderval",isAsc);
        if (num != null){
            wrapper.last("limit " + num);
        }

        List<MemberMien> memberMienList = selectList(wrapper);
        return memberMienList;
    }

}
